import { SearchableType, Searcher } from "../types";
import { buildURL } from "../url_builder";
import { extractCVENumber } from "../utility";

export class ExploitDatabase implements Searcher {
  public baseURL: string;
  public name: string;
  public supportedTypes: SearchableType[] = ["cve"];

  public constructor() {
    this.baseURL = "https://www.exploit-db.com";
    this.name = "ExploitDatabase";
  }

  public searchByCVE(query: string): string {
    const cve = extractCVENumber(query);
    return buildURL(this.baseURL, "/search", { cve: cve });
  }
}
